package com.example.demo.redis.service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.example.demo.mybatis.domain.TUser;

@Service
public class RedisUserServiceImpl {
    private static final Logger logger = LoggerFactory.getLogger(RedisUserServiceImpl.class);

	@Cacheable(cacheNames = { "users" }, key = "'findByAgeTest_key'+#age")
	public List<TUser> findByAgeTest(Integer age) {
		logger.debug("findByAgeTest……");
		
		List<TUser> list = new ArrayList<>();
		TUser u = new TUser();
		u.setAge(10);
		u.setName("aaa");
		u.setId(1l);
		u.setCtime(new Date());
		u.setEmail("aaa@qq.com");
		list.add(u);
		
		u = new TUser();
		u.setAge(12);
		u.setName("bbb");
		u.setId(2l);
		u.setCtime(new Date());
		u.setEmail("bbb@qq.com");
		list.add(u);
		
		return list;
	}

}
